home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libcompress-zlib-perl / examples / filtdef next >
Encoding:
Text File  |  2008-11-08  |  437 b   |  30 lines

  1. #!/usr/bin/perl
  2.  
  3. use strict ;
  4. use warnings ;
  5.  
  6. use Compress::Zlib ;
  7.  
  8. binmode STDIN;
  9. binmode STDOUT;
  10. my $x = deflateInit()
  11.    or die "Cannot create a deflation stream\n" ;
  12.  
  13. my ($output, $status) ;
  14. while (<>)
  15. {
  16.     ($output, $status) = $x->deflate($_) ;
  17.  
  18.     $status == Z_OK
  19.         or die "deflation failed\n" ;
  20.  
  21.     print $output ;
  22. }
  23.  
  24. ($output, $status) = $x->flush() ;
  25.  
  26. $status == Z_OK
  27.     or die "deflation failed\n" ;
  28.  
  29. print $output ;
  30.